<?php
global $VALUTA, $MONTHS2;
$this->load->helper('form');
?>
<h1>История фиксаций сумм по счетам</h1>


<!-- ----------- Фильтр. Начало ----------- -->

<a href='#' onclick="openFilter(); return false;"><img src='<?=config_item('image_path')?>images/icons/funnel.png' width='16' height='16' title='' align=left style="margin-right:5px;"> Фильтр</a><br><br>
<form method=get action='' enctype='multipart/form-data' id='filter' style='display:none;'>
<table class='edit' cellspacing=0>
<?php if($me['level'] > '*') { ?>
<tr>
	<td>Руководитель:</td>
	<td>
		<select name='user_id'>
			<?php  
			printOptionsUsers($structure, 0, @$filter['user_id']);
			?>
		</select> <input type='checkbox' name='include_children' value='1' <?php if(@$filter['include_children']) echo "checked"; ?>> Включать нижестоящих руководителей
	</td>
</tr>
<?php } ?>
<tr>
	<td>Валюта:</td>
	<td>
		<select name='valuta'>
			<option value=''></option>
			<?php foreach($VALUTA as $k => $v) { ?>
				<option value='<?=$k?>' <?php if($k == @$filter['valuta']) echo "selected";?>><?=$v?></option>
			<?php } ?>
		</select>
	</td>
</tr>
<tr>
	<td>Дата:</td>
	<td>
			<select name='day_from'>
				<option value=''></option>
				<?php for($i = 1; $i<=31; $i++) {?>
					<option value='<?=$i?>' <?php if($i == @$filter['day_from']) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select> . <select name='month_from'>
				<option value=''></option>
				<?php foreach($MONTHS2 as $k => $v) {?>
					<option value='<?=$k?>' <?php if($k == @$filter['month_from']) echo "selected"; ?>><?=$v?></option>
				<?php } ?>
			</select> . <select name='year_from'>
				<option value=''></option>
				<?php for($i = 2011; $i<=(date("Y") + 1); $i++) {?>
					<option value='<?=$i?>' <?php if($i == @$filter['year_from']) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<select name='day_to'>
				<option value=''></option>
				<?php for($i = 1; $i<=31; $i++) {?>
					<option value='<?=$i?>' <?php if($i == @$filter['day_to']) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select> . <select name='month_to'>
				<option value=''></option>
				<?php foreach($MONTHS2 as $k => $v) {?>
					<option value='<?=$k?>' <?php if($k == @$filter['month_to']) echo "selected"; ?>><?=$v?></option>
				<?php } ?>
			</select> . <select name='year_to'>
				<option value=''></option>
				<?php for($i = 2011; $i<=(date("Y") + 1); $i++) {?>
					<option value='<?=$i?>' <?php if($i == @$filter['year_to']) echo "selected"; ?>><?=$i?></option>
				<?php } ?>
			</select>
	</td>
</tr>
</table>
<br>
<input type='submit' value='Применить'>
</form>

<!-- ----------- Фильтр. Конец ----------- -->


<script language="javascript" src='<?=config_item('js_path')?>js/table_list.js?<?=time()?>'></script>

<table class='list' cellspacing=0>
<thead>
	<tr>
		<th>Руководитель</th>
		<th>Счёт</th>
		<th>Дата / время</th>
		<th>Сумма на счёте</th>
		<th>Комментарий</th>
		<th>Подтверждение</th>
		<?php if($me['level'] > '*') { ?>
		<th></th>
		<?php } ?>
	</tr>
</thead>
<tbody>
<?php
	foreach($fixes as $f) 
	{
		$val = $VALUTA[$scheta[$f['schet_id']]['valuta']];
		$schet = $scheta[$f['schet_id']];
		$u = $allusers[$schet['user_id']];
		?>
		<tr>
			<td><?=@$u['fio']?></td>
			<td><?=$schet['name']?> <?=$val?> </td>
			<td align=center><?=date("d.m.Y H:i", strtotime($f['date']))?></td>
			<td align=center><?=number_format($f['summ'], 2, $setting['znak_drob'], ' ')?> <?=$val?></td>
			<td><?=nl2br(htmlspecialchars($f['comment']))?></td>
			<td align=center class='action'><a href='<?=UPLOAD_PATH.$f['file']?>' target=_blank>Посмотреть</a></td>
			<?php if($me['level'] > '*') { ?>
			<td>
				<?php if(fixCanEdit($u['id'], $me)) { ?><a href='schet/fix_edit/<?=$f['id']?>'><img src='<?=config_item('image_path')?>images/icons/edit.gif' title='Редактировать'></a><?php } ?>
				&nbsp;
				<?php if(fixCanDelete($u['id'], $me)) { ?><a href='schet/fix_delete/<?=$f['id']?>'><img src='<?=config_item('image_path')?>images/icons/delete.png' title='Удалить' onclick='return confirm("Удалить?")'></a><?php } ?>
			</td>
			<?php } ?>
		</tr>
		<?php
}
?>
</tbody>
</table>



